<?php
namespace Common\Models;
use Common\BaseModel;
class BshopUsersInfo extends BaseModel
{
    public $res;
    public $expire;
    public function initialize()
    {
        parent::initialize();
        $this->setSource('b_shop_users_info');
    }


    public function get_shop_goods_list($param){
        $page  = $param['page'] <= 1 ? 0 : ($param['page'] - 1) * $param['page_size'];
        $page_size  = $param['page_size'];
        $sql=<<<EFO
select uinfo.shop_id,uinfo.shop_name,uinfo.shop_avatar,gcount.goods_count,uinfo.shop_introduction from b_shop_users_info as uinfo
left join (select count(shop_id) as goods_count,shop_id from b_shop_goods where status=1 group by shop_id) as gcount on gcount.shop_id=uinfo.shop_id
where is_disable=1 order by gcount.goods_count DESC LIMIT $page,$page_size 
EFO;
        $get_list = $this->getDI()->get('dbMaster')->fetchAll($sql);
        return $get_list;
    }


    public function find_first($shop_id){
        $get_list = $this->findFirst(array(
            'conditions'=>"shop_id=$shop_id",
            'columns'=>'shop_id,shop_name,shop_avatar,created_at,shop_introduction,is_disable,shop_img',
        ));
        return $get_list;
    }


}
